﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Rdz.Utility
{
	public static class ExceptionUtility
	{
		public static string RecursiveExceptionMessage(Exception ex)
		{
			return RecursiveExceptionMessage(ex, false);
		}

		public static string RecursiveExceptionMessage(Exception ex, bool WithStackTrace)
		{
			string Separator = "--------------------------------------------------------------\r\n";
			return "ERROR: " + ex.Message +
				"\r\n" + (WithStackTrace ? ex.StackTrace + "\r\n" : "") +
				(ex.InnerException != null ? Separator + RecursiveExceptionMessage(ex.InnerException, WithStackTrace) + "\r\n" : "");
		}
	}
}
